package cn.dogger.easyboot.system.controller;

import cn.dogger.easyboot.common.page.annotation.Page;
import cn.dogger.easyboot.common.result.AjaxResult;
import cn.dogger.easyboot.system.domain.bo.SysDeptBO;
import cn.dogger.easyboot.system.domain.dto.SysDeptDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import cn.dogger.easyboot.system.service.SysDeptService;

@Slf4j
@RestController
@RequestMapping("/system/dept")
@Api(value = "部门表",tags = "部门表")
public class SysDeptController {

      final SysDeptService service;

      public SysDeptController( SysDeptService service) {
            this.service = service;
      }


    @Page
    @GetMapping("page")
    @ApiOperation(value = "分页", notes = "分页")
    public AjaxResult page(SysDeptDTO dto) {
        return AjaxResult.page(service.page(dto));
    }

    @PostMapping("add")
    @ApiOperation(value = "新增", notes = "新增")
    public AjaxResult add(@RequestBody SysDeptBO bo) {
        service.add(bo);
        return AjaxResult.success();
    }

    @PostMapping("edit")
    @ApiOperation(value = "编辑", notes = "编辑")
    public AjaxResult edit(@RequestBody SysDeptBO bo) {
        service.edit(bo);
        return AjaxResult.success();
    }


    @GetMapping("/{id}")
    @ApiOperation(value = "根据主表id详情", notes = "根据主表id详情")
    public AjaxResult detailById(@PathVariable String id){
        return AjaxResult.success(service.detailById(id));
    }


    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除多个id", notes = "删除多个id")
    public AjaxResult removeByIds(@PathVariable String...ids){
        service.removeByIds(ids);
       return AjaxResult.success();
    }

}